<template>
	<G__TopNav/>
	<div>
		<div>{{ name }}</div>
		<div>
			<button @click="copy">复制文本</button>
		</div>

		<div>
			<button @click="copyImg">复制图片</button>
		</div>
	</div>
</template>

<script lang="ts" setup>
import { clipboard, nativeImage } from 'electron';

const name = 'Michael Ray';

function copy() {
	clipboard.writeText(name);

	const info = clipboard.readText();

	console.log('复制成功', info);   //写一个div提示
}

function copyImg() {
	const image = nativeImage.createFromPath('public/favicon.ico');

	//复制图片
	clipboard.writeImage(image);

	//粘贴图片
	const imgSrc = clipboard.readImage().toDataURL();
	console.log(imgSrc);   //base64的地址
}
</script>

<script lang="ts">
import { computed, defineComponent } from 'vue'
import { mapGetters, mapState, useStore } from "vuex";
import G__TopNav from "@/components/TopNav.vue";

export default defineComponent({
	name: "page__clipboard",
	components: {G__TopNav},
	data() {
		return {
			num: 1234567
		}
	},

	setup() {
		// 组合是API中使用store
		const store = useStore()

		const storeX = computed(() => store.state.moduleA.x)

		return {
			storeX
		}
	}
})
</script>

<style scoped lang="less">

</style>
